<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>收银日报表</title>
<link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap.min.css" />
<link rel="stylesheet" href="${contextPath}/static/bootstrap/css/bootstrap-table.css" />
<link rel="stylesheet" href="${contextPath}/static/ace/assets/css/ace.css" />
<link rel="stylesheet" href="${contextPath}/static/bootstrap/css/bootstrap-select.css" />
<link rel="stylesheet" href="${contextPath}/static/bootstrap/css/bootstrap-select.css" />
<link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap-datetimepicker.min.css" />
<link rel="stylesheet" href="${contextPath}/static/ztree/css/zTreeStyle.css" />
<script src="${contextPath}/static/statistics/js/jquery.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap.min.js"></script>
<script src="${contextPath}/static/bootstrap/js/bootstrap-table.js"></script>
<script src="${contextPath}/static/bootstrap/js/bootstrap-select.min.js"></script>
<script src="${contextPath}/static/bootstrap/js/defaults-zh_CN.min.js"></script>
<script src="${contextPath}/static/bootstrap/js/bootstrap-table-zh-CN.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.min.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.fr.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${contextPath}/static/ztree/js/jquery.ztree.core-3.5.js"></script>
<script src="${contextPath}/static/ztree/js/jquery.ztree.excheck-3.5.js"></script>
<script src="${contextPath}/static/util/dateutils.js"></script>
<script src="${contextPath}/static/util/protutils.js"></script>
<style type="text/css">
	input.combo-input{
		padding:7px 4px; 
	}
	.panel{
		margin-bottom:0px;	
	}
	.bs-actionsbox .btn-group button {
	    width: 45%;
	}
	.bootstrap-select:not([class*="col-"]):not([class*="form-control"]):not(.input-group-btn) {
	    width: 100%;
	}
	.list-group-item{
		padding:5px 6px;
		font-size:11px;
	}
	#zoneCode .list-group .list-group-item:first-child{
		padding:7px 6px;
	}
	.panel-heading::after {
	    content: "";
	    display: block;
	    clear: both;
	}
	.caret{
		color:#ABBAC3;
	}
	.bootstrap-select > .btn{
		color:#ABBAC3 !important;
		background-color: #fff !important;
		text-shadow:none;
		border-width:1px;
	}
	.bootstrap-select > .btn:hover, .bootstrap-select > .btn:focus:hover, .bootstrap-select > .btn.focus:hover, .bootstrap-select > .btn:active:hover, .bootstrap-select > .btn:focus:active, .btn-default:focus:active, .open > .btn.dropdown-toggle, .open > .btn-default.dropdown-toggle, .open > .btn.dropdown-toggle:hover, .open > .btn-default.dropdown-toggle:hover, .open > .btn.dropdown-toggle:focus, .open > .btn-default.dropdown-toggle:focus, .open > .btn.dropdown-toggle.focus, .open > .btn-default.dropdown-toggle.focus, .open > .btn.dropdown-toggle:active, .open > .btn-default.dropdown-toggle:active {
	    background-color: #fff !important;
	    border-color: #ABBAC3;
	}	
	.fixed-table-footer{
	    overflow: auto;
	}	
	.dropdown-header{
		cursor:pointer;
	}		
	.fixed-table-footer{
		overflow:hidden;
	}
</style>
</head>
<body>
 <div class="panel panel-default" id="panel">
  <div class="panel-heading">
 				<h3 class="panel-title pull-left" style="text-shadow:2px 1px 2px #ABBAC3">收银日报表</h3>
 				<h5 class="pull-right" id="timeCount" style="margin-top: 0;margin-bottom: 0;"></h5>
 			</div>
 			<input type="hidden" id="orginAreas" value="${orginAreas }"/>
            <div class="panel-body ">
                <form class="form-horizontal" class="form-inline" style="margin-bottom: 5px;"
				action="${contextPath}/ktcount/exportExcelCollectMoney" method="post" id="exportExcel">
					<input id="sortName" name="sortName" type="hidden" value="SHORT_CODE" />
					<input id="sortOrder" name="sortOrder" type="hidden" value="asc">
                    <div class="form-group">
                        <div class="col-sm-2">
                             <select class="selectpicker" data-live-search="true" title="请选择店铺名称" data-live-search-placeholder="搜索" data-actions-box="true" id="shopName">
							</select>
							<input type="hidden" name="shopId" id="shopId" />
							<input type="hidden" name="shopIdName" id="shopIdName" />
							<input type="hidden" name="operator" id="operator" />
                        </div>
          				<div class="col-sm-2">
                            <input type="text" class="form-control" id="turnCreateDate" name="turnCreateDate" placeholder="查询开始时间" readonly />
                        </div>
                        <div class="col-sm-2">
							<input type="text" class="form-control" id="bindCreateDate" name="bindCreateDate" placeholder="查询结束时间" readonly />
                        </div>
                    	<div class="col-sm-7">
                        	<label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio0" checked> 自定
						    </label>
							<label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio1" > 今天
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio2" > 昨天
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio3" > 本周
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio4" > 上周
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio5" > 本月
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio6" > 上月
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio7" > 本季度
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio8" > 上季度
						    </label>
						    <label class="radio-inline">
						        <input type="radio" name="dateRadio" id="dateRadio9" > 今年
						    </label>
                        </div>
						
                    </div>
                   	<div class="form-group">
                   		<div class="col-sm-2">
                            <select class="selectpicker" data-live-search="true" title="请选择收银员" data-live-search-placeholder="搜索" data-actions-box="true" id="clerks">
							</select>
							
                        </div>  
                        <div class="col-sm-6"> 
                           <label class="radio-inline">
                        	报表类型：
                        </label>
                        <label class="radio-inline">
						    <input type="radio" name="searchTypeRadio" value="0" checked > 默认
						</label>
						<label class="radio-inline">
					        <input type="radio" name="searchTypeRadio" value="1" > 门店汇总
						</label>
                        <label class="radio-inline">
						    <input type="radio" name="searchTypeRadio" value="2" > 按收银员汇总
						</label>
		
					    <label class="radio-inline">
					        <input type="radio" name="searchTypeRadio" value="3" > 日期汇总
					    </label>
					    <label class="radio-inline">
					        <input type="radio" name="searchTypeRadio" value="4" > 方式汇总
					    </label>
					    </div>
                        <div class="col-sm-1" style="text-align:left;">
                            <input type="range" min="50" max="100" defaultValue="60" step="5" value="0">
                        </div>
                        <div class="col-sm-2" style="text-align:left;">
	                        <button type="button" style="margin-left:50px;" id="btn_query" class="btn btn-sm btn-info">查询</button>
	                    </div>            
                   	</div>
                   	<input type="hidden" id="colsTitles" name="colsTitles" />
                    <input type="hidden" id="colsFields" name="colsFields" />
                </form>
            </div>
        </div>      
 <div id="toolbar" class="btn-group" style="margin-left:15px">
 			<button id="btn_refresh" type="button" class="btn btn-sm btn-warning">
                <span class="glyphicon glyphicon-refresh icon-refresh" aria-hidden="true"></span>刷新
            </button>
            <button onclick="exportExcel();" type="button" class="btn btn-sm btn-success">
                <span class="glyphicon glyphicon-file" aria-hidden="true"></span>导出
            </button>
            <button onclick="doPrint();" type="button" class="btn btn-sm btn-default">
                <span class="glyphicon glyphicon-print" aria-hidden="true"></span>打印
            </button>
            <button type="button" class="btn btn-sm btn-success"
				onclick="javascript:window.history.go(-2);window.close();">
				<span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span>返回</button>
        </div>         
       <!--startprint--> 
		<table id="kt_CM"></table>
		<!--endprint-->

</body>
<script type="text/javascript">
var ISFIRSTLOAD = true,
LASTSEARCHTYPEVAL = $("input[name='searchTypeRadio']:checked").val();
$(function () {
	timeCount();
	initDatetimepicker([ "turnCreateDate", "bindCreateDate" ]);
    //1.初始化Table
    getShop();
    $('#shopName').on('changed.bs.select',onShopSelectChange);
    $('#clerks').on('changed.bs.select',onClerkSelectChange);
});
function getShop(){
	$.ajax({
        url: '${contextPath}/ktcount/getShops', //localhost:8080
        data:{"zoneCode":"","shopType":"\'中深\'"},
        type: 'post',
        success: function (data) {
           	var data = data.data;
           	if(data.length == 0)
           		return;
			var html = '';
        	for(var i = 0;i < data.length;i++){
        		html +='<option value="'+data[i]["shopId"]+'">'+data[i]["shopName"]+'</option>';
        	}
        	$("#shopName").html(html);
        	$('#shopName').selectpicker('refresh');
        	$("#shopName").selectpicker('val',data[0]["shopId"]);
        	$("#shopId").val(data[0]["shopId"]);
        	$("#shopIdName").val(data[0]["shopName"]);
        	getClerks()
        	oTable.Init();
        },
        error: function (error) {
            alert(error)
        }
    })
}
function getClerks(){
	$.ajax({
        url: '${contextPath}/ktcount/getClerks', //localhost:8080
        data:{"shopId":$("#shopName").val()},
        type: 'post',
        success: function (data) {
           	var data = data.data;
			var html = '';
        	for(var i = 0;i < data.length;i++){
        		html +='<option value="'+data[i]["USER_NAME"]+'">'+data[i]["USER_NAME"]+'</option>';
        	}
        	$("#clerks").html(html);
        	$('#clerks').selectpicker('refresh');
        },
        error: function (error) {
            alert(error)
        }
    })
}
var TableInit = function () {
    var oTableInit = new Object();
    function sumCol(data,colName){
    	var count = 0;
    	for(var i=0;i<data.length;i++){
    		count+= parseFloat(data[i][colName])
    	}
    	return parseFloat(count.toFixed(2));
    }
    function removeJsonEle(OrgArr,filterArr,toFilterField){
    	var newArr = OrgArr;
    	for(j = 0,filterArrLen = filterArr.length;j < filterArrLen;j++){
	    	for(var i = 0,OrgArrLen = OrgArr.length;i < OrgArrLen;i++){
	    		if(OrgArr[i][toFilterField] == filterArr[j]){
	    			newArr = OrgArr.splice(i, 1); 
	    			break;
	    		}
	    	}
    	}
    	return OrgArr;
    }
    function getSearchType4(){
    	var OrgArr = [{
            field: 'ROWNUM_',
            title: '序号',
            footerFormatter:function(data){
            	return "合计";
            }
        }, {
            field: 'TYPE_NAME',
            title: '支付类型',
            sortable: true
        }, {
            field: 'TOTAL_TYPE',
            title: '类型合计(元)',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"TOTAL_TYPE");
            	return count;
            }
        }, {
            field: 'COUNT_TYPE',
            title: '支付次数',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"COUNT_TYPE");
            	return count;
            }
        }, {
            field: 'BENEFIT_AMT',
            title: '优惠合计(元)',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"BENEFIT_AMT");
            	return count;
            }
        }, {
            field: 'TOTAL_SUM',
            title: '实收合计(元)',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"TOTAL_SUM");
            	return count;
            }
        }, {
            field: 'TOTAL_PERCENT',
            title: '支付百分比',
            isSum: true,
            sortable: true,
            formatter:function(data){
            	return (data*100).toFixed(2)+"%"
            }
        },{
            field: 'COUNT_PERCENT',
            title: '支付次数百分比',
            isSum: true,
            sortable: true,
            formatter:function(data){
            	return (data*100).toFixed(2)+"%"
            }
        }]
    	return OrgArr;
    }
    function triggerRemoveJsonEle(){
    	var OrgArr = [{
            field: 'ROWNUM_',
            title: '序号',
            footerFormatter:function(data){
            	return "合计";
            }
        },{
            field: 'OPERATOR_ID',
            title: '收银员编号',
            sortable: true
        },{
            field: 'USER_NAME',
            title: '收银员',
            sortable: true
        }, {
            field: 'GB_DATE',
            title: '操作日期',
            sortable: true
        }, {
            field: 'XJ',
            title: '现金(元)',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"XJ");
            	return count;
            }
        }, {
            field: 'POS',
            title: 'POS刷卡(元)',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"POS");
            	return count;
            }
        }, {
            field: 'NHWXZ',
            title: '农行微信主扫(元)',
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"NHWXZ");
            	return count;
            }
        }, {
            field: 'NHWXB',
            title: '农行微信被扫(元)',
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"NHWXB");
            	return count;
            }
        }, {
            field: 'YLZX',
            title: '银联在线(元)',
            sortable: true
        }, {
            field: 'POSYH',
            title: 'POS优惠(元)',
            sortable: true
        }, {
            field: 'YSSHWX',
            title: '商户微信(元)',
            sortable: true
        }, {
            field: 'YSSHZFB',
            title: '商户支付宝(元)',
            sortable: true
        }, {
            field: 'SCW',
            title: '商城微信支付(元)',
            sortable: true
        }, {
            field: 'QT',
            title: '其他(元)',
            sortable: true
        }, {
            field: 'SURPLUS',
            title: '现金结余(元)',
            sortable: true
        }, {
            field: 'CASH_AMT',
            title: '现金缴存(元)',
            isSum: true,
            sortable: true
        }, {
            field: 'TOTAL',
            title: '合计',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"TOTAL");
            	return count;
            }
        }, {
            field: 'BA',
            title: '优惠金额(元)',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"BA");
            	return count;
            }
        }, {
            field: 'STOTAL',
            title: '实收金额',
            isSum: true,
            sortable: true,
            footerFormatter:function(data){
            	var count = 0;
            	count += sumCol(data,"STOTAL");
            	return count;
            }
        }]
    	var searchType = $("input[name='searchTypeRadio']:checked").val();
    	if(searchType == 0)
    		return removeJsonEle(OrgArr,["SURPLUS","CASH_AMT"],"field")
    	else if(searchType == 1)
    		return removeJsonEle(OrgArr,["OPERATOR_ID","USER_NAME","GB_DATE","SURPLUS","CASH_AMT"],"field")
    	else if(searchType == 2)
    		return removeJsonEle(OrgArr,["GB_DATE","SURPLUS","CASH_AMT"],"field")
    	else if(searchType == 3)
    		return removeJsonEle(OrgArr,["OPERATOR_ID","USER_NAME"],"field")
    	else if(searchType == 4)
    		return getSearchType4();
    }
    function getFieldIndex(fieldName){
    	var orgArr = triggerRemoveJsonEle();
    	for(var i = 0,orgArrLen = orgArr.length;i < orgArrLen;i++){
    		if(fieldName == orgArr[i]["field"]){
    			return i;
    		}
    	}
    }
    //初始化Table
    oTableInit.Init = function () {
		$("#btn_query").removeClass("btn-info").addClass("btn-default");
        $('#kt_CM').bootstrapTable({
            url: '${contextPath}/ktcount/getktCollectMoney',         //请求后台的URL（*）
            method: 'POST',                      //请求方式（*）
            toolbar: '#toolbar',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: true,                   //是否显示分页（*）
            sortable: true,                     //是否启用排序
            sortStable:true,
            queryParams: oTableInit.queryParams,//传递参数（*）
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber:1,                       //初始化加载第一页，默认第一页
            pageSize: 10000,                       //每页的记录行数（*）
            pageList: [10, 50, 100,10000],        //可供选择的每页的行数（*）
            strictSearch: true,
            showColumns: true,                  //是否显示所有的列
            minimumCountColumns: 2,             //最少允许的列数
            clickToSelect: true,                //是否启用点击选中行
            height: $(window).height()-$("#panel").height(),                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
            showToggle:true,                    //是否显示详细视图和列表视图的切换按钮
            cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            showFooter:true,
            contentType : "application/x-www-form-urlencoded",
            columns: triggerRemoveJsonEle(),
            onLoadSuccess: function(data){
            	$("#btn_query").removeClass("btn-default").addClass("btn-info");
            	refreshFooterData(data.rows);
            },
            onColumnSwitch:function(field, checked){
            	var fieldIndex = getFieldIndex(field);
            	toggleFootrowTd(fieldIndex,checked)
            }
        });
    };
    oTableInit.queryParams = function (params) {
		var searchType = $("input[name='searchTypeRadio']:checked").val();
		$("#sortName").val(params.sort);
		$("#sortOrder").val(params.order);
    	var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            limit: params.limit,   //页面大小
            offset: params.offset,  //页码
            sortName: params.sort || "",
            sortOrder: params.order || "desc",
            shopId:$("#shopName").val() || -1,
            turnCreateDate : $("#turnCreateDate").val(),
            bindCreateDate: $("#bindCreateDate").val(),
            operator: $("#clerks").val(),
            searchTypeRadio:searchType
        };
        return temp;
    };
    return oTableInit;
}
var oTable = new TableInit();
$("#btn_refresh").bind('click',function(){
	$("#clerks").selectpicker('val','');
	$("#dateRadio0").prop("checked",true); 
	$("input:radio[name='searchTypeRadio'][value=0]").prop("checked",true); 
	$("#turnCreateDate").val("");
	$("#bindCreateDate").val("");
})
$("#btn_query").bind("click",function(){
	if($("#btn_query").hasClass("btn-default")){
		return;
	}
	$("#btn_query").removeClass("btn-info").addClass("btn-default");
	var searchType = $("input[name='searchTypeRadio']:checked").val();
	if(searchType != LASTSEARCHTYPEVAL){
		$("#kt_CM").bootstrapTable('destroy');
		oTable.Init();
		LASTSEARCHTYPEVAL = searchType;
		return;
	}
	$('#kt_CM').bootstrapTable('refresh', { url: '${contextPath}/ktcount/getktCollectMoney'});
})
$("input[name='dateRadio']").bind("click",function(){
	var radioId = $(this).attr("id");
	var oDateUtil = new DateUtil();
	var jsonDate = {};
	switch(radioId){
	case "dateRadio1":
		jsonDate = oDateUtil.getToday()
		break;
	case "dateRadio2":
		jsonDate = oDateUtil.getYesterday();
		break;
	case "dateRadio3":
		jsonDate = oDateUtil.getThisWeek();
		break;
	case "dateRadio4":
		jsonDate = oDateUtil.getLastWeek();
		break;
	case "dateRadio5":
		jsonDate = oDateUtil.getThisMonth();
		break;
	case "dateRadio6":
		jsonDate = oDateUtil.getLastMonth();
		break;
	case "dateRadio7":
		jsonDate = oDateUtil.getThisQuarter();
		break;
	case "dateRadio8":
		jsonDate = oDateUtil.getLastQuarter();
		break;
	case "dateRadio9":
		jsonDate = oDateUtil.getThisYear();
		break;
	default:
		jsonDate = oDateUtil.init();
		break;
	}
	if(!(jsonDate["o"] == "" || "" == jsonDate["t"])){
		$("#turnCreateDate").val(jsonDate["o"]+" 00:00:00");
		$("#bindCreateDate").val(jsonDate["t"]+" 23:59:59");
	}else{
		$("#turnCreateDate").val(jsonDate["o"]);
		$("#bindCreateDate").val(jsonDate["t"]);
	}
})
var exportExcel = function() {
    var visibleCols = $('#kt_CM').bootstrapTable('getVisibleColumns');
    var fields = "",titles = "";
	for(var i = 0,visibleColsLen = visibleCols.length;i<visibleColsLen;i++){
		fields += visibleCols[i]["field"]+",";
		titles += visibleCols[i]["title"]+",";
	}
	$("#colsTitles").val(titles.substring(0,titles.length-1));
	$("#colsFields").val(fields.substring(0,fields.length-1));
	$("#exportExcel").submit();

}
function initDatetimepicker(arr) {
	arr.forEach(function(item, index, input) {
		$('#' + item).datetimepicker({
			language : 'zh-CN',
			weekStart : 1,
			todayBtn : 1,
			todayHighlight : 1,
			startView : 3,
			forceParse : 0,
			showMeridian : 1,
			format : "yyyy-mm-dd",
			autoclose : true,
			minView : "month",
			initialDate:trans2FormatDate(new Date())
		}).on('changeDate', function(ev){
		    var idVal = $(this).attr("id");
		    var date = ev.date;
		    if(idVal == "turnCreateDate"){
		    	$("#turnCreateDate").val(date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" 00:00:00")
		    }else{
		    	$("#bindCreateDate").val(date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" 23:59:59")
		    }
		});
	})

}
function trans2FormatDate(date){
	date.setDate(date.getDate() - 1);
	return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
}
function onShopSelectChange(e){
	$("#shopId").val($("#shopName").val()||-1);
	$("#shopIdName").val($("#shopName option:selected").text());
	$("#operator").val("");
	getClerks();
}
function onClerkSelectChange(e){
	$("#operator").val($("#clerks").val());
}
function doPrint() {
    var fillTable = new FillTable(),oDateUtil = new DateUtil();
	var formatDate = "查询区间："+oDateUtil.getRegionTime($('#turnCreateDate').val(),$('#bindCreateDate').val());
	//layer.msg("正在打印报表...");
	var css = {"csTb":{"clz":"bootstrap-table","css":""},"csTr":{"clz":"","css":""},"csTh":{"clz":"","css":TABLEFONTSIZE},"csTd":{"clz":"","css":TABLEFONTSIZE}}
	var data = $('#kt_CM').bootstrapTable('getData');
    var cols = $('#kt_CM').bootstrapTable('getVisibleColumns');
    var cp = {"tpl":3,"cnt":[{"title":$("#shopIdName").val(),"clz":"title","css":"font-size:20px;margin-top:5px;text-align:center"},{"title":"收银日报表","clz":"","css":"letter-spacing:2px;font-size:28px;font-weight:bold;margin-top:5px;text-align:center"},{"title":formatDate,"clz":"","css":"font-size:16px;margin-top:5px;margin-bottom:5px;text-align:center"}]}
	var fr = {"tpl":1,"cnt":[]};
    fillTable.ft(cols,data,css,cp,true,fr);
	$("head").html("").append('<link rel="stylesheet" href="${contextPath}/static/common/table.css">');
	setTimeout(function(){
		$("body").css("background","none").html(fillTable.tb)
		//layer.closeAll();
    	window.print();
    	window.location.reload(); //刷新当前页面
	},500)
}

function toggleFootrowTd(fieldIndex,checked){
	var td = $(".fixed-table-footer").find("td").get(fieldIndex);
	if(!checked)
		td.style.display = "none";
	else{
		td.style.display = "";
	}
}

function refreshFooterData(data){
	var visibleCols = $('#kt_CM').bootstrapTable('getVisibleColumns');
	var tds = $(".fixed-table-footer").find("td");
	for(i in visibleCols){
		if(visibleCols[i].hasOwnProperty("myFooterFormatter")){
			$(tds.get(visibleCols[i]["fieldIndex"])).find(".th-inner").html(visibleCols[i]["myFooterFormatter"].call(visibleCols[i],data))
		}
	}
}

function timeCount(){
	var oDateUtil = new DateUtil();
	setInterval(function(){
		var date = new Date();
		var formatDate = oDateUtil.formatDate(date,"yyyy-MM-dd hh:mm:ss",true);
		$("#timeCount").html(formatDate)
	},1000)
}
var TABLEFONTSIZE = "font-size:14px";
function setTableFontSize(val){
	val = val ? val : (cookie.get("ktCollectMoneyfontSize") ? parseInt(cookie.get("ktCollectMoneyfontSize")) : 14)
	TABLEFONTSIZE = "font-size:"+ val+"px";
	$('input[type="range"]').val(val*5);
	$("table").css("font-size",val);
}
$('input[type="range"]').bind('input',function(){
	var val = parseFloat($(this).val()/5);
	cookie.set("ktCollectMoneyfontSize",val,7);
	setTableFontSize(val);
})
function timeCount(){
	var oDateUtil = new DateUtil();
	setInterval(function(){
		var date = new Date();
		var formatDate = oDateUtil.formatDate(date,"yyyy-MM-dd hh:mm:ss",true);
		$("#timeCount").html(formatDate)
	},1000)
}

</script>
</html>